using System;
using System.Windows.Forms;

namespace VisualEditorUILib
{

    /// <summary>
    /// represents button of control on Toolbox panel
    /// </summary>
    public partial class GeneratorControlButton : Button
    {

        #region Variables

        //holds type of standard Ui control
        Type type;

        #endregion

        #region Contrtuctors

        //default constructor
        public GeneratorControlButton()
        {
            InitializeComponent();
            this.MouseDown += new MouseEventHandler(Button_Mousedown);
        }

        public GeneratorControlButton(Type _type)
        {
            type = _type;
            base.Text = type.Name;
            this.MouseDown += new MouseEventHandler(Button_Mousedown);
        }

        #endregion

        #region Properties

        public Type GControlType
        {
            get { return type; }
        }

        #endregion

        #region Event handlers

        private void Button_Mousedown(object sender, MouseEventArgs e)
        {
            //we will pass the data that user wants to drag DoDragDrop method is used for holding data
            //DoDragDrop accepts two paramete first paramter is data(image,file,text etc) and second paramter 
            //specify either user wants to copy the data or move data

            GeneratorControlButton source = (GeneratorControlButton)sender;
            DoDragDrop(source.Text, DragDropEffects.Copy);
        }

        #endregion

    }
}
